# build images
IMAGE_REPO = gluenet
IMAGE_NAME = $(IMAGE_REPO)/$(APP)
IMAGE_TAG ?= latest
NEW_TAG ?= 0.0.1

DOCKERFILE_PATH ?= deploy/docker/common/Dockerfile

image: build-env
	docker build \
	  -t $(IMAGE_NAME):$(IMAGE_TAG) \
	  --build-arg APP=$(APP) \
	  -f $(DOCKERFILE_PATH) \
	  .
	docker image prune -f

multi_image: build-env
	docker buildx build \
	  -platform linux/amd64, linux/arm64 \
	  -t $(IMAGE_NAME):$(IMAGE_TAG) \
	  --build-arg APP=$(APP) \
	  -f $(DOCKERFILE_PATH) \
	  .
	docker image prune -f

cleanimg: build-env
	@docker rmi `docker images | grep $(IMAGE_NAME) | awk '{print $$1":"$$2}'`

pushimg: build-env
	docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):$(NEW_TAG)
	docker push $(IMAGE_NAME):$(NEW_TAG)